package com.sang.web;

import com.sang.pojo.User;
import com.sang.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserServiceImpl userService;

    @GetMapping("/{id}")
    public User queryById(@PathVariable("id") String username, HttpServletRequest request) {

        System.out.println("service层的queryById方法实现");
//        //测试降级回调函数逻辑
////        if("sang".equals(username)){
////            //如果服务
// 层传参为sang的话抛出异常  此时应该回调函数
////            throw new RuntimeException("测试降级函数");
////        }

        return userService.queryById(username,request);
    }
}